<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>list</title>
    <style>
        h1 {
            text-align: center;
        }

        span {
            font-weight: bold;
        }

        * {
            margin: 0;
            padding: 0;
        }

        li {
            list-style: none;
        }
    </style>
    <script th:src="@{/webjars/jquery/3.3.1/jquery.js}"></script>
    <script>
        function exit() {
            if (confirm("确认要退出系统吗")) {
                location.href = '/info/logout';
            }
        }
        function ckCommit() {
            var id = $("[name=id]").val();
            var oldPassword1 = $("[name=oldPassword1]").val();
            var oldPassword2 = $("[name=oldPassword2]").val();
            var newPassword1 = $("[name=newPassword1]").val();
            var newPassword2 = $("[name=newPassword2]").val();

            if (oldPassword2==''|| newPassword1=='' || newPassword2==''){
                alert("请填写完整信息");
                return false;
            }
            if (oldPassword1!=oldPassword2){
                alert("旧密码输入错误");
                return false;
            }
            if (newPassword1.length<6){
                alert("密码不能少于6位");
                return false;
            }
            if (newPassword1!=newPassword2){
                alert("两次密码不同");
                return false;
            }

            $.post("info/modify?password="+newPassword1+"&id="+id,function (data) {
                if (data=="ok"){
                    alert("修改成功");
                    location.href="/";
                }
                else {
                    alert("修改失败");
                }
            })

        }
    </script>
</head>
<body>

<table>
    <tr>
        <td colspan="2"><h1>商务会员管理系统</h1></td>
        <td></td>
    </tr>
    <tr>
        <td colspan="2">
            用户名 <span th:text="${session.user.name}"></span>&nbsp;&nbsp;&nbsp;&nbsp;
            用户类型:<span th:text="${session.user.typeName}"></span>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:;" th:onclick="'javascript:exit();'">退出</a>
        </td>
        <td></td>
    </tr>
    <tr>
        <td>
            <ul>
                <li><a th:href="@{/info/toModify}">修改密码</a></li>
                <li><a th:href="@{/info/list}">查看所有会员</a></li>
                <li><a th:href="@{/info/toadd}">新增会员</a></li>
            </ul>
        </td>

        <td>
            <div style="border: 3px solid black">
                <h1>新增会员12321</h1>
                <form action="/info/add" method="post" enctype="multipart/form-data">
                   <input name="name"><br/>
                   <input name="password" type="password"><br/>
                   <input name="mu" type="file"><br/>
                    <select name="type_id">
                        <option th:each="type:${session.allType}" th:value="${type.id}" th:text="${type.name}" th:selected="${type.id==2}"></option>
                    </select>
                    <input type="submit" th:value="提交"/>
                </form>
            </div>
        </td>

    </tr>
</table>


</body>
</html>